#ifndef _XHASH_H_
#define _XHASH_H_
#include "xtypes.h"
#include "xaux.h"
#include "xbuffer.h"
#include "string.h"



template <class _Init>
inline size_t _Hash_value(_Init _Begin, _Init _End)
{	// hash range of elements
	size_t _Val = 2166136261U;
	while(_Begin != _End)
		_Val = 16777619U * _Val ^ (size_t)*_Begin++;
	return (_Val);
}


template<class _Kty>
inline size_t hash_value(const _Kty& _Keyval)
{	// hash _Keyval to size_t value one-to-one
	return ((size_t)_Keyval ^ _HASH_SEED);
}

inline size_t hash_value(const char *_Str)
{	// hash NTBS to size_t value
	return (_Hash_value(_Str, _Str + ::strlen(_Str)));
}

inline size_t hash_value(const wchar_t *_Str)
{	// hash NTWCS to size_t value
	return (_Hash_value(_Str, _Str + ::wcslen(_Str)));
}







#endif //_XHASH_H_

